<?php 
require_once 'init.php';
require_once 'ckLogin.php';
require_once 'dbClasses'.DIRECTORY_SEPARATOR.'config.php';
require_once 'dbClasses'.DIRECTORY_SEPARATOR.'dbConn.php';

$db = new dbConn();
//
$act = $_GET['act'];
$id = $_GET['id'];
//提交处理
if(strtoupper($_SERVER['REQUEST_METHOD'])=='POST'){
	$question = $_POST['question'];
	if(empty($act)){
		$db->sql = "INSERT INTO fun_quiz(question,create_time,create_user) VALUE('".$question."',UNIX_TIMESTAMP(),'".$_SESSION['userName']."')";
	}else{
		$db->sql="UPDATE fun_quiz SET question = '".$question."' WHERE id = ".$id;
	}
	$db->doExecute();
	?>
			<script type="text/javascript">
				this.location.replace('funQuiz.php');
			</script>
	<?php
}
if(!empty($act)){
	$db->sql = "SELECT * FROM fun_quiz WHERE id = ".$id;
	$funQuiz = $db->doResult();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo APPLICATION;?></title>
<!--                       CSS                       -->
<!-- Reset Stylesheet -->
<link rel="stylesheet" href="resources/css/reset.css" type="text/css" media="screen" />
<!-- Main Stylesheet -->
<link rel="stylesheet" href="resources/css/main.css" type="text/css" media="screen" />
<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
<link rel="stylesheet" href="resources/css/invalid.css" type="text/css" media="screen" />
<style type="">
	span{width: 85px;font-weight: bold;display: block;float: left;}
</style>
<!-- jQuery -->
<script type="text/javascript" src="resources/scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function($) {
	$("form").submit(function(){
		if( !$("input[name='question']").val() ){
			alert("问题为空！");
			return false;
		}
	});
});
</script>
<!-- jQuery Configuration -->
<script type="text/javascript"
	src="resources/scripts/simpla.jquery.configuration.js"></script>
<!-- Facebox jQuery Plugin -->
<script type="text/javascript" src="resources/scripts/facebox.js"></script>
<!-- jQuery WYSIWYG Plugin -->
<script type="text/javascript" src="resources/scripts/jquery.wysiwyg.js"></script>

</head>

<body>
	<div id="body-wrapper">
		<!-- Wrapper for the radial gradient background -->
		
		<div id="main-content">
			<!-- Page Head -->
			<h2>欢迎使用<?php echo APPLICATION;?>管理后台</h2>
			<p id="page-intro"></p>

			<div class="clear"></div>
			<!-- End .clear -->

			<div class="content-box">
				<!-- Start Content Box -->

				<div class="content-box-header">

					<h3>趣味问题<?php if (empty($act)) echo "添加";else echo "修改";?></h3>

					<div class="clear"></div>

				</div>
				<!-- End .content-box-header -->

				<div class="content-box-content">

				<!-- Start Notifications -->
				
				<!-- End Notifications -->
					<div class="tab-content default-tab" id="tab1">
						<form action="#" method="post">
							<fieldset>
								<!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
								<p>
									<label><?php if (empty($act)) echo "新的趣味问题";else echo "修改趣味问题";?></label>
									<input class="text-input large-input" type="text" id="large-input" name="question" value="<?php echo $funQuiz['question'];?>"/>
								</p>
								<p>
									<input class="button" type="submit" value="<?php if (empty($act)) echo "添加";else echo "修改";?>" />
									<input class="button" type="reset" value="清空" />
								</p>

							</fieldset>

							<div class="clear"></div>
							<!-- End .clear -->

						</form>

					</div>
					<!-- End #tab2 -->

				</div>
				<!-- End .content-box-content -->

			</div>
			<!-- End .content-box -->

			<div class="clear"></div>

			<div id="footer">
				<small> <!-- Remove this notice or replace it with whatever you want -->
					&#169; Copyright 2009 Your Company | Powered by <a
					href="http://themeforest.net/item/simpla-admin-flexible-user-friendly-admin-skin/46073">Simpla
						Admin</a> | <a href="#">Top</a>
				</small>
			</div>
			<!-- End #footer -->

		</div>
		<!-- End #main-content -->

	</div>
</body>


<!-- Download From www.exet.tk-->
</html>
